Repository navigation
Host core: one Space shortcut, roving choice and play button for every UI - #113
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The tests never call handlePlaybackShortcut, leaving held-Space toggle suppression and default-prevention behavior for accepted and rejected events unverified.
1 open issue
What changed in this PR
Builds on the headless view model by centralizing keyboard navigation and play-button behavior in host core, reducing duplication between the default and VS Code UIs.
Changes:
- Adds shared Space-shortcut, roving-navigation, and play-button helpers while preserving existing public wrappers.
- Aligns shortcut handling for held keys, enclosing dialogs, and portaled overlays.
- Documents the helpers and adds unit tests for shortcut eligibility, navigation, and button state.
| File | Description |
|---|---|
packages/host/vscode-ui/src/view-controls.tsx |
Uses shared roving navigation for the mode switch. |
packages/host/vscode-ui/src/scope-switch.tsx |
Uses shared roving navigation for scope choices. |
packages/host/vscode-ui/src/playback.tsx |
Delegates playback behavior to core with custom-element exclusions. |
packages/host/core/test/keyboard.test.mjs |
Adds shortcut, navigation, and play-button tests. |
packages/host/core/src/view-model.ts |
Defines shared play-button action, direction, and label. |
packages/host/core/src/ui/view-controls.tsx |
Uses shared horizontal navigation for view tabs. |
packages/host/core/src/ui/playback.tsx |
Preserves public wrappers around shared playback helpers. |
packages/host/core/src/keyboard.ts |
Implements framework-free shortcut and navigation helpers. |
packages/host/core/src/index.ts |
Exports the new helpers and types. |
docs/guides/host-core.md |
Documents shared keyboard and play-button behavior. |
Review effort: Balanced
agorischek
force-pushed
the
headless-keys
branch
from
November 20, 2026 23:45
db05ee9 to
b8a696b
Compare
agorischek
force-pushed
the
headless-view-model
branch
from
November 21, 2026 00:43
8d77a7c to
dfe2e20
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 00:43
b8a696b to
a9c0b36
Compare
agorischek
force-pushed
the
headless-view-model
branch
from
November 21, 2026 01:37
dfe2e20 to
2f5e4fd
Compare
agorischek
force-pushed
the
headless-keys
branch
2 times, most recently
from
November 21, 2026 15:19
1378b59 to
cd6a8c1
Compare
agorischek
force-pushed
the
headless-view-model
branch
from
November 21, 2026 15:19
2f5e4fd to
484f242
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 16:08
cd6a8c1 to
809e9ad
Compare
agorischek
force-pushed
the
headless-view-model
branch
2 times, most recently
from
November 21, 2026 17:39
415c5f4 to
fcdeef9
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 17:39
809e9ad to
ba8e73b
Compare
agorischek
force-pushed
the
headless-view-model
branch
from
November 21, 2026 18:28
9fb13a8 to
a385848
Compare
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 18:28
ba8e73b to
128bf6f
Compare
…y UI
The default UI, the VS Code UI and Primer each had their own Space-to-play handler, with different lists of elements
that keep Space and different rules for held keys and enclosing dialogs, their own play-button naming, and three
copies of the arrow, Home and End rule for radio groups and tabs. The core now has them, framework-free:
- `handlePlaybackShortcut` and `isPlaybackShortcut`, with `spaceKeeping` and a `keeps` option for a design system's
custom elements: one press, one toggle; a Space-keeping element that encloses the listener doesn't count; a key
from a portaled overlay is never the shortcut;
- `rovingIndex(key, index, count, orientation?)`;
- `playButton(projection, beforeLabel, afterLabel)`: `{action, direction, label}`.
`spaceTogglesPlayback`, `playLabel`, `handlePlaybackKey` and `playButtonState` keep their names and use them.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek
force-pushed
the
headless-keys
branch
from
November 21, 2026 19:07
128bf6f to
1f8053d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #112 (the headless view model). Third item of the headless-host plan, G5 ("keyboard and button behaviour").
Why
Each UI had its own copy of three behaviours, and the copies disagreed:
ui/playback.tsx(spaceTogglesPlayback),vscode-ui/src/playback.tsx(handlePlaybackKey), Primerblocks.tsxplayLabel,playButtonState(VS Code, and verbatim in Primer)ViewSwitch, VS Code's scope switch and mode switch, and PrimerWhat's in the core now
These are framework-free and take any keydown event:
handlePlaybackShortcut(event, projection, keeps?)andisPlaybackShortcut(event, keeps?). The rules, which combine all three copies:spaceKeeping, pluskeepsfor a design system's custom elements);rovingIndex(key, index, count, orientation?): wraps;horizontalorverticalkeeps to one axis.playButton(projection, beforeLabel, afterLabel)→{action: 'pause' | 'play' | 'show', direction, label}. The icon stays the UI's.The existing public names keep working and now use these:
spaceTogglesPlaybackandplayLabel(default UI);handlePlaybackKeyandplayButtonState(VS Code UI, which passes VSCode Elements' tags askeeps).Behaviour changes
Docs and tests
docs/guides/host-core.md(the view model section) documentsplayButtonand the keyboard helpers.packages/host/core/test/keyboard.test.mjs(node:test, with a small DOM stand-in) covers:rovingIndexaxes, wrapping and other keys;playButton.Run locally:
tools check --fast: pass.node --test test/keyboard.test.mjs test/view-model.test.mjs: 12/12.